<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Infotech Ltd.
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2007/07/10 08:57:50 $)
// $RCSfile: client_modernbillv5.php,v $ : $Revision: 1.2 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

require_once ("./modules/tickets/functions_ticketmain.php");
require_once ("./modules/tickets/functions_ticketcore.php");
require_once ("./modules/tickets/functions_clienttickets.php");
require_once ("./includes/functions_users.php");
require_once ("./includes/functions_customfields.php");
require_once ("./includes/functions_html.php");
require_once ("./includes/data_mimelist.php");
$template->loadLanguageSection("tickets_auditlogs", TEMPLATE_FILE);
$template->loadLanguageSection("tickets");

if (empty($_SWIFT["user"]["userid"]))
{
	$template->assign("errormessage", $_SWIFT["language"]["perminvalid"]);
	echo $template->displayTemplate("header");
	echo $template->displayTemplate("footer");
	exit;
}

if (MBAREA == "dashboard")
{
		$_emaillist = getUserEmailList();

		$_SWIFT["helpdeskTickets"] = array();

		$_ticketstatusidlist = array();
		foreach ($_SWIFT["statuscache"] as $key=>$val)
		{
			if ($val["displayinmainlist"] == 1)
			{
				$_ticketstatusidlist[] = $val["ticketstatusid"];
			}
		}

		$dbCore->query("SELECT * FROM `". TABLE_PREFIX ."tickets` AS tickets WHERE `userid` = '". intval($_SWIFT["user"]["userid"]) ."' AND `ticketstatusid` IN (". buildIN($_ticketstatusidlist) .") ORDER BY `lastactivity` DESC;");
		while ($dbCore->nextRecord())
		{
			$_SWIFT["helpdeskTickets"][] = array(
			"hdTicketID" => $dbCore->Record["ticketid"],
			"hdTicketKey" => iif($_SWIFT["settings"]["t_eticketid"]=="seq",$dbCore->Record["ticketid"], $dbCore->Record["ticketmaskid"]), // Use primary key if you do not manage ticket keys.
			"hdTicketSubject" => htmlspecialchars($dbCore->Record["subject"]),
			"hdTicketDateCreated" => intval($dbCore->Record["dateline"]),
			"hdTicketDateModified" => intval($dbCore->Record["lastactivity"]),
			"hdTicketStatusID" => 2, // 2 = Open
		);
			
		}

		if ($module->isRegistered(MODULE_NEWS))
		{
			require_once ("./modules/news/client_modernbillv5.php");
		}
}
?>